<template>
	<view class="content">
		<view class="customerList">
			<view class="messageList">
				<label for="" style="font-size: 26rpx;letter-spacing: 5rpx;color: #62b074;font-weight: 600;">套餐名称:</label>
				<input type="text" v-model="meal.name" value="" placeholder="请输入详细信息" />
			</view>
			<view class="messageList">
				<label for="" style="font-size: 26rpx;letter-spacing: 5rpx;color: #62b074;font-weight: 600;">赠送金额:</label>
				<input type="text" v-model="meal.giveMoney" value="" placeholder="请输入详细信息" />
			</view>
			<view class="messageList">
				<label for="" style="font-size: 26rpx;letter-spacing: 5rpx;color: #62b074;font-weight: 600;">套餐价格:</label>
				<input type="text" v-model="meal.price" value="" placeholder="请输入详细信息" />
			</view>
		</view>
		<view class="afrim" @click="save()">保存</view>
	</view>
</template>

<script>
	import Api from '@/common/api';
	import {
		mapState
	} from 'vuex';
	export default {
		computed: {
			...mapState(['hasLogin', 'userInfo'])
		},
		data() {
			return {
				meal: {},
			};
		},
		onLoad(options) {
			let id = options.id;
			let storeId = options.storeId;
			if (typeof storeId != 'undefined') {
				this.meal.storeId = storeId;
			}
			if (typeof id != 'undefined') {
				this.getMealById(id);
			}
		},
		methods: {
			handleChange(e) {
						this.value = e.detail.value;
						this.meal.isXufei = this.value;
						console.log(this.value)
					},
			async getMealById(mealId) {
				let data = await Api.apiCall('get', Api.qsg.getMealById, {
						mealId: mealId
					});
				if(data){
					this.meal = data;
				}
			},
			async save() {
				let params = {
					id: this.meal.id,
					name: this.meal.name,
					price: this.meal.price,
					giveMoney:this.meal.giveMoney,
					storeId: this.meal.storeId
				}
				let data = await Api.apiCall('post', Api.qsg.createRecharge, params);
				console.log(data)
				if(data){
					uni.showModal({
						title: '提示',
						content: '已成功保存套餐.',
						success: function(res) {
							if (res.confirm) {
							} else if (res.cancel) {
					
							}
						}
					});
				}
			}
		}
	}
</script>

<style>
	.afrim{
		width: 650rpx;
		height: 80rpx;
		background: #0DA944;
		border-radius: 30rpx;
		font-size: 28rpx;
		font-family: Source Han Sans CN;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 80rpx;
		text-align: center;
		position: fixed;
		bottom: calc(100% - 95%);
		margin-left: 40rpx;
	}
	.customerType {
		display: inline-block;
		height: 80rpx;
		line-height: 80rpx;
		vertical-align: top;
		text-align: right;
		padding-right: 30rpx;
		font-size: 30rpx;
	}

	.pickerType {
		width: 540rpx;
		display: inline-block;
		vertical-align: top;
		text-align: left;
	}

	.pickerType view {
		height: 80rpx;
		line-height: 80rpx;
		font-size: 30rpx;
	}

	.upBox {
		padding: 0 30rpx;
	}

	.upBox text {
		display: inline-block;
		padding: 20rpx 0;
	}

	.messageList {
		width: 750rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		border-bottom: 1px solid #F8F8F8;
	}

	.messageList label {
		display: inline-block;
		height: 80rpx;
		line-height: 80rpx;
		vertical-align: top;
		text-align: right;
		padding-right: 30rpx;
		font-size: 30rpx;
	}

	.messageList input {
		height: 80rpx;
		vertical-align: top;
		display: inline-block;
		line-height: 80rpx;
		font-size: 28rpx;
	}

	.fan {
		position: relative;
		padding: 30rpx 0;
	}

	.fan button {
		position: absolute;
		top: 30rpx;
		left: 0;
		width: 750rpx;
		height: 480rpx;
		background: none;
		border: none;
	}

	.fanMian {
		width: 750rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.fanMian image {
		width: 690rpx;
		height: 480rpx;
	}

	.examTit {
		width: 750rpx;
		height: 80rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		line-height: 80rpx;
		font-size: 30rpx;
	}

	.examTit text {
		font-size: 24rpx;
		color: #ff1d31;
	}

	.examTit {
		width: 750rpx;
		height: 80rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
		line-height: 80rpx;
		font-size: 30rpx;
	}

	.examTit text {
		font-size: 24rpx;
		color: #ff1d31;
	}

	.fan {
		position: relative;
		padding: 30rpx 0;
	}

	.fan button {
		position: absolute;
		top: 30rpx;
		left: 0;
		width: 750rpx;
		height: 480rpx;
		background: none;
		border: none;
	}

	.fanMian {
		width: 750rpx;
		padding: 0 30rpx;
		box-sizing: border-box;
	}

	.fanMian image {
		width: 690rpx;
		height: 480rpx;
	}
</style>
